﻿using System;

namespace OperationPlugins.Models
{
    [AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = true)]
    public sealed class GetPropertyValueAttribute : Attribute, IPropertyFilter
    {
        private readonly Type _declaringType;
        private readonly string[] _propertyNames;

        /// <summary>
        /// Gets the type that declares the property.
        /// </summary>
        Type IPropertyFilter.DeclaringType
        {
            get { return _declaringType; }
        }

        /// <summary>
        /// Gets the property names.
        /// </summary>
        string[] IPropertyFilter.PropertyNames
        {
            get { return _propertyNames; }
        }

        /// <summary>
        /// Initializes a new instance of the GetPropertyValueAttribute class.
        /// </summary>
        /// <param name="declaringType">The type that declares the property.</param>
        /// <param name="propertyNames">The property names.</param>
        public GetPropertyValueAttribute(Type declaringType, params string[] propertyNames)
        {
            if (declaringType == null)
            {
                throw new ArgumentNullException("declaringType");
            }

            _declaringType = declaringType;
            _propertyNames = propertyNames;
        }
    }
}